package com.shujia.bigdata.map;

import java.util.ArrayList;

public class Demo5 {
    public static void main(String[] args) {

        A a = new A();

        a.setA("java");
        Object a1 = a.getA();

        String s = (String) a1;
        System.out.println(s);

        /**
         * 如果不知道泛型，默认是Object
         *
         */
        A<String> a2 = new A<>();
        a2.setA("java");
        String a3 = a2.getA();
        System.out.println(a3);



    }
}

/**
 * 泛型：对类型进行限制
 * 泛型类
 * 泛型只在编译时起作用，编译过程中会进行类型擦除   编译之后T变成Object
 *
 */
class A<T> {

    private T a;

    public T getA() {
        return a;
    }

    public void setA(T a) {
        this.a = a;
    }

    @Override
    public String toString() {
        return "A{" +
                "a=" + a +
                '}';
    }


}
